//package com.ctsi.security.controller;
//
//import com.ctsi.commons.util.UtilValidate;
//import com.ctsi.commons.util.request.UtilHttp;
//import com.ctsi.commons.util.response.Page;
//import com.ctsi.commons.util.response.PageUtil;
//import com.ctsi.framework.security.util.SecurityUtil;
//import com.ctsi.security.domain.DataObject;
//import com.ctsi.security.service.DataObjectService;
//import com.ctsi.security.service.DataObjectTypeService;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.List;
//import java.util.Map;
//
//
//public class DataObjectController {
//	private DataObjectService dataObjectService;
//	private DataObjectTypeService dataObjectTypeService;
//
//
//	/** *********************数据对象CRUD***************start********************************* */
//	public ModelAndView viewDataObject(HttpServletRequest request,
//			HttpServletResponse respone) {
//		String parent  = request.getParameter("parent");
//		if(UtilValidate.isEmpty(parent)){
//			String thisid = request.getParameter("thisid");
//			if(UtilValidate.isNotEmpty(thisid)){
//				DataObject dataObject = dataObjectService.findByDataObjectId(thisid);
//				if(!dataObject.getDataObjectTypeId().equals(dataObject.getParent())){
//					parent = dataObject.getParent();
//				}
//			}
//		}
//		request.setAttribute("parent", parent);
//		return new ModelAndView("security/dataObject/dataObject");
//	}
//
	// 查询系统数据对象
//	public ModelAndView dataObjectPage(HttpServletRequest request,
//			HttpServletResponse response) {
//		int skipResults = 0;
//		int pageSize = Page.DEFAULT_PAGE_SIZE;
//		String start = request.getParameter("start");
//		String limit = request.getParameter("limit");
//		if (limit != null && !limit.trim().equals("")) {
//			pageSize = Integer.parseInt(limit);
//		}
//		if (start != null && !start.trim().equals(""))
//			skipResults = Integer.parseInt(start);
//		//当前登录用户
//		String userLogin= SecurityUtil.getUser().getLoginId();
//		//获得当前方法的功能ID
//
//		Map param = UtilHttp.filterBlank(request.getParameterMap());
//		String parent = (String)param.get("parent");
//		Page<DataObject> page = null;
//		boolean per =false;
//		if(UtilValidate.isEmpty(parent)){
//			per=true;
//		}
//		page = dataObjectService.queryDataObjectWithDataPermission(userLogin, "systemDataObjectType", "SELECT", param, pageSize, skipResults, per);
//		PageUtil<DataObject> out = new PageUtil<DataObject>(page);
//		super.outJson(out, response);
//		return null;
//	}
//
//
//	// 打开添加数据对象
//	public ModelAndView addDataObject(HttpServletRequest request,
//			HttpServletResponse response) {
//		String dataObjectTypeId = dataObjectTypeService.findSelectDoType();
//		request.setAttribute("dataObjectTypeId", dataObjectTypeId);
//		return new ModelAndView("security/dataObject/addDataObject");
//	}
//	// 保存系统数据对象
//	public ModelAndView saveDataObject(HttpServletRequest request,
//			HttpServletResponse response) {
//		return this.saveOrUpdateDataObject(request, response);
//	}
//	//更新系统数据对象
//	public ModelAndView updateDataObject(HttpServletRequest request,
//			HttpServletResponse response) {
//		return this.saveOrUpdateDataObject(request, response);
//	}
//	// 保存和更新系统数据对象
//	public ModelAndView saveOrUpdateDataObject(HttpServletRequest request,
//			HttpServletResponse response) {
//		String id = request.getParameter("ID");
//		id = id == null ? "" : id;
//		String dataObjectId = request.getParameter("dataObjectId");
//		dataObjectId = dataObjectId == null ? "" : dataObjectId;
//		String dataObjectName = request.getParameter("dataObjectName");
//		dataObjectName = dataObjectName == null ? "" : dataObjectName;
//		String dataObjectTypeId = request.getParameter("dataObjectTypeId");
//		dataObjectTypeId = dataObjectTypeId == null ? "" : dataObjectTypeId;
//		String description = request.getParameter("description");
//		description = description == null ? "" : description;
//		String parent = request.getParameter("parent");
//		parent = parent == null ? "" : parent;
//		DataObject dataObject = new DataObject();
//		dataObject.setId(id);
//		dataObject.setDataObjectId(dataObjectId);
//		dataObject.setDataObjectName(dataObjectName);
//		dataObject.setDescription(description);
//		dataObject.setDataObjectTypeId(dataObjectTypeId);
//		if(UtilValidate.isEmpty(parent)){
//			dataObject.setParent(dataObjectTypeId);
//		}else{
//			dataObject.setParent(parent);
//		}
//		request.setAttribute("dataObject", dataObject);
//		String doTypeId = dataObjectTypeService.findSelectDoType();
//		request.setAttribute("dataObjectTypeId", doTypeId);
//		if (id.equals("")) {
//			if(dataObjectService.valDataObjectId(dataObjectId)){
//				super.SetErrMsg(request,"数据库中已存在该ID,请重新填写!");
//				return new ModelAndView("security/dataObject/addDataObject");
//			}else{
//				try{
//					dataObjectService.saveDataObject(dataObject);
//				}catch(Exception e){
//					super.SetErrMsg(request,"保存失败，请检查此id是否已存在");
//					return new ModelAndView("security/dataObject/addDataObject");
//				}
//			}
//		} else {
//			dataObjectService.updateDataObject(dataObject);
//		}
//		super.setReturnMsg(request, "保存成功");
//
//		return new ModelAndView("security/dataObject/editDataObject");
//	}
//
//	// 打开修改页面
//	public ModelAndView editDataObject(HttpServletRequest request,
//			HttpServletResponse response) {
//		String ID = request.getParameter("ID");
//		ID = ID == null ? "" : ID;
//		DataObject dataObject = null;
//		List<DataObject> listDataObject = dataObjectService.findDataObject(
//				new String[] { "ID" }, new Object[] { ID });
//		if (listDataObject.size() > 0) {
//			dataObject = listDataObject.get(0);
//		} else {
//			dataObject = new DataObject();
//		}
//		request.setAttribute("dataObject", dataObject);
//		String dataObjectTypeId = dataObjectTypeService.findSelectDoType();
//		request.setAttribute("dataObjectTypeId", dataObjectTypeId);
//		return new ModelAndView("security/dataObject/editDataObject");
//	}
//
//	// 删除系统功能
//	public ModelAndView delDataObject(HttpServletRequest request,
//			HttpServletResponse response) {
//		String IDS = request.getParameter("IDS");
//		String[] arrayId = IDS.substring(0, IDS.lastIndexOf(",")).split(",");
//		String doIds=request.getParameter("doIds");
//		String[] arrayDoId=doIds.split(",");
//		for (int i = 0; i < arrayId.length; i++) {
//			DataObject dataObject = null;
//			List<DataObject> listDataObject = dataObjectService.findDataObject(
//					new String[] { "ID" }, new Object[] { arrayId[i] });
//			if (listDataObject.size() > 0) {
//				dataObject = listDataObject.get(0);
//			} else {
//				dataObject = new DataObject();
//			}
//			dataObjectService.removeDataObject(arrayId[i],arrayDoId[i]);
//		}
//		return null;
//	}
//
//	public DataObjectService getDataObjectService() {
//		return dataObjectService;
//	}
//
//	public void setDataObjectService(DataObjectService dataObjectService) {
//		this.dataObjectService = dataObjectService;
//	}
//
//	public DataObjectTypeService getDataObjectTypeService() {
//		return dataObjectTypeService;
//	}
//
//	public void setDataObjectTypeService(DataObjectTypeService dataObjectTypeService) {
//		this.dataObjectTypeService = dataObjectTypeService;
//	}
//
//	/** *********************数据对象CRUD***************end*********************************** */
//
//}
